package demoMod.nanaki.cards.nanaki;

import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import demoMod.nanaki.NanakiMod;
import demoMod.nanaki.powers.NotePower;
import demoMod.nanaki.utils.GetWaitAction;

public class Scherzo extends AbstractNanakiCard {
    public static final String ID = NanakiMod.makeID("Scherzo");

    private static final CardStrings cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    public static final String NAME = cardStrings.NAME;
    public static final String DESCRIPTION = cardStrings.DESCRIPTION;
    public static final String IMG_PATH = "cards/Scherzo";

    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = CardRarity.COMMON;
    private static final CardTarget TARGET = CardTarget.ALL;

    private static final int COST = 1;

    public Scherzo() {
        super(ID, NAME, NanakiMod.getResourcePath(IMG_PATH), COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.baseBlock = 8;
        this.baseMagicNumber = this.magicNumber = 2;
    }

    @Override
    public Runnable getUpgradeAction() {
        return () -> {
            upgradeBlock(3);
            upgradeMagicNumber(2);
        };
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new GainBlockAction(p, p, this.block));
        addToBot(GetWaitAction.doAndWait(() -> {
            AbstractMonster mo = AbstractDungeon.getRandomMonster();
            if (mo == null) {
                return;
            }
            addToTop(new ApplyPowerAction(mo, p, new NotePower(mo, this.magicNumber)));
        }, 0.0F));
    }
}
